﻿<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <title>添加新的商品</title>
 <script type="text/javascript" src="../ueditor/editor_config.js"></script>
<script type="text/javascript" src="../ueditor/editor_all.js"></script>
<link rel="stylesheet" href="../ueditor/themes/default/ueditor.css"/>
 <link rel="stylesheet" rev="stylesheet" href="../css/style.css" type="text/css" media="all" />
<script language="JavaScript" type="text/javascript">
var city = new Array();
 city=[
            ["男装","女装","男鞋","女鞋","配饰","箱包","其它"],
            ["教材","娱乐类","文学类","理工类","其它"],
            ["日常用品","清洁用品","卫浴用品","卧室床品","其它"],
            ["运动器材","饰品","纪念品","玩具","布偶","其它"],
            ["纸质类","工具类","笔类","其它"],
            ["手机数码","配件","二手电子产品","其它"],
            ["其它"]
        ]
  //遍历二维数组，详细分类赋值
 var value=new Array();
 var count = 0;

 for(i = 0;i<city.length;i++)
	 {
		value[i]= new Array();
	 	var child = city[i];

	 	for(j=0;j<child.length;j++)
	 	{
			count++;
	 		value[i][j]= count;
	 	}
	 }
function getCity(){
    var sltProvince=document.forms["form"].elements["mainclass"];
    var sltCity=document.forms["form"].elements["classify"];
    var proID = sltProvince.selectedIndex-1; //获得类别的Id(一位数组id)
    var mainclassCity=city[proID];//获得 类别id对应的一位数组
    sltCity.length=1;
    sltCity.remove(0);
	for(var i=0;i<mainclassCity.length;i++){
		t = value[proID][i];
   	sltCity[i]=new Option(mainclassCity[i],t);            
    }
}

function show()
{	
	document.getElementById("myEditor").style.display = "block";
}
function hide()
{	
	document.getElementById("myEditor").style.display = "none";
}

//提交并验证表单
function CheckForm()
{ 
	/*
	var jscaption = document.form.caption.value;
	if(jscaption.length==0){ 
	 alert("商品名称不能为空的！");
	 document.form.caption.focus();
	 return   false;
	 }
	 if(jscaption.length>20){ 
	 alert("商品名称太长了，必须在20字符内！");
	 document.form.caption.focus();
	 return   false;
	 }
	 var jscount= document.form.count.value;
	 if(!jscount.match(/^(-|\+)?\d+$/)||jscount.length==0)
	 {
	  alert("商品数量不能小于1!");document.form.count.value="1";
	  document.form.count.focus();
	  return   false;
	 }
	
	 var jsgold= document.form.gold.value;
	 if(!jsgold.match(/^[1-9]\d+\.*\d*|0\.\d*[1-9]\d*$/))
	 {		
		alert("该商品的售价金额输入错误");
		document.form.gold.value="1";
		document.form.gold.focus();
		return false;
	 }*/
	   document.getElementById("form").action="<%= basePath%>main/addproduct.action";
	  if(editor.hasContents()){  //提交条件满足时提交内容
    	editor.sync();           //此处的editor是页面实例化出来的编辑器对象
    	document.getElementById('form').submit();
	}
	return   true;
}
function check()
{
document.getElementById("aa").style.display="";
}

function link(){
}
</script>
</head>
<body class="ContentBody">
 <form action="" method="post" name="form" id="form" target="mainFrame">
  <div class="MainDiv">
  <table class="CContent" border="0" cellpadding="0" cellspacing="0" width="99%">
    <tbody>
      <tr>
        <th class="tablestyle_title">添加商品页面</th>
      </tr>
      <tr>
        <td class="CPanel">
           <table style="width: 100%;" border="0" cellpadding="0" cellspacing="0">
          <tbody>
            <tr>
              <td align="left"> 
			  <input name="Submit" value="保存" class="button" onclick="CheckForm()" type="button" />　 
			  <input name="Submit2" value="返回" class="button" onclick="window.history.go(-1);" type="button" /> </td>
            </tr>
            <tr>
              <td width="100%">
              <fieldset style="height: 100%;"> <legend>商品信息</legend>
              <table style="width: 100%;" border="0" cellpadding="2" cellspacing="1">
                <tbody>
                  <tr>
                    <td align="left" nowrap="nowrap" width="20%">商品名称：
                     <input name="product.caption" class="text" style="width: 350px;" size="40" type="text" />20字内<span class="red"> *为必填,下同</span> </td>
                    <td id="isExist"><span color="blue">该商品已经存在，无需添加，请选择查询修改</span></td>
                  </tr>
                  <tr>
                    <td style="vertical-align: top;">商品分类：
					<select id="mainclass" name="mainclass" onchange="getCity()">
					<option value="0">请选择商品类别</option>
					<option value="1">服装饰品</option>
					<option value="2">图书杂志</option>
					<option value="3">生活用品 </option>
					<option value="4">文娱用品</option>
					<option value="5">学习用品</option>
					<option value="6">电子产品</option>
					<option value="7">其它用品</option>
					</select>
					<select id="classify" name="product.classify" >
						<option value="0">选择详细分类</option>
					</select>
                    </td>
                  </tr>
                  <tr>
                    <td align="left" nowrap="nowrap" width="3%">商品数量：
                     <input name="product.inventory" class="text" style="width: 50px;" size="40" value="1" type="text" />（件/份/条等）<span class="red"> *</span> </td>
                  </tr>
                  <tr>
                    <td align="left" nowrap="nowrap" width="3%">购买限制：
                    <select name="product.limit">
                    <option selected="selected" value="1">仅贫困生购买</option>
                    <option value="2">仅非贫困生购买</option>
                    <option value="0">都可以购买</option>
                    </select>
					金币价格： <input name="product.goldPrice" id="gold" class="text" style="width: 50px;" size="40" type="text" />金币<span class="red"> *</span> 
					爱心币价格： <input name="lovegold" id="product.lovePrice" class="text" style="width: 50px;" size="40" value="0" type="text" />爱心币<span class="red"> *</span> </td>
                  </tr>
                  <tr>
                    <td align="left" nowrap="nowrap" width="13%">其捐献者： 
                    <input name="product.donor" class="text" style="width: 300px;" size="40" type="text" />
                    </td>
                  </tr>
                  <tr>
                    <td align="left" nowrap="nowrap" width="3%">其关键词： 
                    <input name="product.keyword" class="text" style="width: 300px;" size="40" type="text" /><span class="red">*</span>(该关键词供用户检索商品时匹配，多个关键词请用英文状态下的';'隔开) </td>
                  </tr>
                  <tr>
                    <td align="left" nowrap="nowrap">商品备注说明：</td>
                  </tr>
                  <tr>
                    <td colspan="3"><textarea id="textarea" name="product.remark" rows="3" cols="80"> </textarea>(100字符内)
					</td>
				  </tr>
				  <tr>
                    <td align="left" nowrap="nowrap" width="3%">是否添加商品详情： <input type="radio" id="test11" name="test11" value="1" onclick="show();"/>添加详情
						<input type="radio" id="test11" checked name="test11" value="2" onclick="hide();"/>不添加
                    </td>
                  </tr>
			    </tbody>
			   </table>
				  
			  </fieldset>
			  </td>
			</tr>
	    <!--商品详情信息-->
			<tr>
            <td width="100%">
			<div id="myEditor" style="display:none"> 
              <fieldset style="height: 100%;"> <legend>商品信息</legend>
              <table style="width: 100%;" border="0" cellpadding="2" cellspacing="1">
                <tbody>
                <tr>
                <!-- 通过request取值 -->
                <td>
                <script type="text/plain" id="baiduUe">请在这里编辑商品详情！</script>
				</td>
				</tr>
			  </tbody>
			  </table>
			</fieldset>
			</div>
			</td>
		</tr>	
		 </tbody>
		</table>
		</td>
	  </tr>
	</tbody>
  </table>
  </div>
 </form>
 <script type="text/javascript">
   var editor = new baidu.editor.ui.Editor({
	   			textarea:'product.detailPro.proState'
    });
    editor.render("baiduUe");
</script>
</body></html>